import {Answer} from "../../model/answer"
import {AnswerHandle} from "../../model/answer-handle"
import {User} from "../../model/user"
import {Score} from "../../model/score"

Page({
    data: {
        answers: [],
	    startMaskShow: true,
        loadingType: 'loading'
    },
    cpsPaging: null,
    async onLoad() {
    },
    async onShow() {
        wx.showLoading({
            mask: true
        })
        const answer = wx.getStorageSync('answer')
        if (answer) {
            const score = await Score.uploadPoint({
                point: 0,
                duration: 0,
                checkpoint_id: answer
            })
            wx.removeStorageSync('answer');
        }
        const cps = await Answer.getCheckpoints()
        const answerHandle = new AnswerHandle(cps.data.items)
        const answers = answerHandle.handleCheckpoints()
        const user = new User()
        const info = await user.getUserInformation()
        wx.hideLoading()
        this.setData({
            answers,
            info
        })
    },
    onRuleTap() {
        wx.navigateTo({
	        url: '/pages/answerRule/answerRule'
        })
    },
	onKnow() {
		this.setData({
			startMaskShow: false
		})
	}
})
